/**
 * Created by henrick on 2017/3/29.
 */
(function () {
    window.ajax = {
        formSubmit: function (id,success,dataType) {
            var url = $(id).attr('action');
            var type = $(id).attr('method');
            var dataType = dataType || 'json';
            $.ajax({
                url : url,
                type: type,
                data: $(id).serialize(),
                dataType: dataType,
                success: success,
                complete: function () {
                    
                }
            });
        },
        getQiniuUploadToken: function () {  //获取七牛云上传token
            $.ajax({
                url: '/index.php?s=admin/api/getqiniuuploadtoken',
                success: function (data) {
                    if(data.err){
                        layer.msg(data.msg,{
                            icon:2,
                            time:1000
                        });
                        return false;
                    }
                    return data.token;
                }
            });
        }
    }

    window.page = {
        go : function (url) {
            Pace.start();
            $.ajax({
                url : url,
                success: function (data) {
                    $(".wrapper").html(data);
                }
            });
        }
    }
})(window);